<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('f:\wamp\www\simpletest\autorun.php');
require_once ('../lib/init.php');

class TestTemplate extends UnitTestCase {
    
    function setUp(){
        global $login_button;
        try{
            $me = getOneself();
        }catch(Exception $e){
            print($login_button);
            exit();
        }
    }
    
    //refer to http://www.simpletest.org/en/unit_test_documentation.html
    function testCallFQL(){ 
    
        $id = 612139051;
        $messageQuery = "SELECT thread_id, author_id, body, created_time FROM message WHERE author_id = '$id' AND thread_id IN (
                    	SELECT thread_id FROM thread WHERE (folder_id = 0 OR folder_id = 1) AND updated_time > ".QUERY_SINCE."
                	) AND created_time > ".QUERY_SINCE;
            
        $response = callFQL($messageQuery);
        
        print_r($response);

        $this->assertNotNull($response);
        $this->assertTrue(is_array($response));
        
        $query = null;
        $response = callFQL($query);
        $this->assertNull($response);
        
        $query = "";
        $response = callFQL($query);
        $this->assertNull($response);
        
        $query = "select 123";
        try{
            $response = callFQL($query);
            $this->assertTrue(false);
        }catch(Exception $e){
            $this->assertTrue(true);
        }
        
 
    }
}
?>